/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.Demo;

import cn.yzc.mapper.DbMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * <p>Project: MybatisPro - po1</p>
 * <p>Powered by yzc On 2023-10-07 14:32:47</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
public class po1 {
    public static void main(String[] args) {
      try (
              //获取mybatis-config.xml输入流
              InputStream is = Resources.getResourceAsStream("mybatis-config.xml")
      ){
          //创建会话工厂
          SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(is);
          //创建会话
          SqlSession ss = sf.openSession();
          //获取到mapper
          DbMapper dm = ss.getMapper(DbMapper.class);
          System.out.println(dm.version());
          System.out.println(dm.dbs());
          System.out.println(dm.tbs());
          System.out.println(dm.select());
          System.out.println(dm.byId(1));
      }catch (Exception e){
          e.printStackTrace();
      }
    }
}